﻿
var cuFoilNum = "";
//PP 半固化片种类数
var ppTypeNumberA = 0;
//PP/PCF料号PPPartNo
var LOTPPRCFPartNum1 = "";
var LOTPPRCFPartNum2 = "";

$(function () {

    //Lot 批号(上条码)
    $("input[name='lotBatch']").keydown(function (e) {

        if (e.keyCode == 13) {

            //验证
            var plntNum = $("input[name='plntNum']").val();
            var staffNum = $("input[name='staffNum']").val();
            var shiftNum = $("select[name='shiftNum']").find("option:selected").val();;
            var equipmentCode = $("input[name='equipmentCode']").val();

            if (Topro.Util.isNullOrEmptySpance(plntNum)) {
                Topro.UI.Tip_short_warning("厂号不能为空.");
                return false;
            }

            if (Topro.Util.isNullOrEmptySpance(staffNum)) {
                Topro.UI.Tip_short_warning("员工号不能为空.");
                return false;
            }

            if (Topro.Util.isNullOrEmptySpance(shiftNum)) {
                Topro.UI.Tip_short_warning("请选择班次.");
                return false;
            }

            if (Topro.Util.isNullOrEmptySpance(equipmentCode)) {
                Topro.UI.Tip_short_warning("设备编码不能为空.");
                return false;
            }

            var data = {
                content: $(this).val()
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/LotBatch",
                data: data,
                success: function (res) {
                    if (res.success) {
                        $("input[name='lotBatch']").val(res.data.lotBatch);
                        $("input[name='partNum']").val(res.data.partNum);
                        $("input[name='heapNumber']").val(res.data.heapNumber);
                        $("input[name='materialType']").val(res.data.materialType);
                        //Book Buildup Structure满本结构
                        if (!Topro.Util.isNullOrEmptySpance(res.data.bookBuildupStructure)) {
                            $("input[name='bookBuildupStructure']").val(res.data.bookBuildupStructure)
                        } else {
                            $("input[name='bookBuildupStructure']").val('')
                        }
                        //Press Program 压合程式
                        if (!Topro.Util.isNullOrEmptySpance(res.data.pressProgram)) {
                            $("input[name='pressProgram']").val(res.data.pressProgram)
                        } else {
                            $("input[name='pressProgram']").val('')
                        }
                        //Secion Quan 含切片的板数
                        if (!Topro.Util.isNullOrEmptySpance(res.data.secionQuan)) {
                            $("input[name='secionQuan']").val(res.data.secionQuan)
                        } else {
                            $("input[name='secionQuan']").val('')
                        }
                        //提示
                        if (!Topro.Util.isNullOrEmptySpance(res.data.tips)) {
                            $(".console").html(res.data.tips);
                        } else {
                            $(".console").html('');
                        }

                        //获取焦点
                        $("input[name='programbarCode']").focus();
                    } else {
                        $("input[name='lotBatch']").val("");
                        $("input[name='partNum']").val("");
                        $("input[name='heapNumber']").val("");
                        $("input[name='materialType']").val("");
                        $("input[name='bookBuildupStructure']").val("");
                        $("input[name='pressProgram']").val("");
                        $("input[name='secionQuan']").val("");

                        $(".console").html("");
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }
    });

    //物料/程式信息(下条码)
    $("input[name='programbarCode']").keydown(function (event) {

        if (event.which == 13) {

            var content = $(this).val();

            var data = {
                content: content
            };

            //还原
            ppTypeNumberA = 0;

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/ProgrambarCode",
                data: data,
                success: function (res) {
                    if (res.success) {
                        debugger;
                        $(".barCode").html(content);
                        //铜箔编号
                        cuFoilNum = res.data.cuFoilNum;
                        //LOT料号1
                        LOTPPRCFPartNum1 = res.data.pprcfPartNum1;
                        //LOT料号2
                        LOTPPRCFPartNum2 = res.data.pprcfPartNum2;

                        var ppTypeNumberAReg = new RegExp("^000000");
                        if (!ppTypeNumberAReg.test(LOTPPRCFPartNum1)) {
                            ppTypeNumberA++;
                        }

                        var ppTypeNumberBReg = new RegExp("^000000");
                        if (!ppTypeNumberBReg.test(LOTPPRCFPartNum2)) {
                            ppTypeNumberA++;
                        }

                        if (ppTypeNumberA != 0) {
                            $("input[name='ppTypeNumber']").val(ppTypeNumberA);
                        }

                        //判断是否有值
                        var pressProgram = $("input[name='pressProgram']").val();
                        if (Topro.Util.isNullOrEmptySpance(pressProgram)) {
                            $("input[name='pressProgram']").val(res.data.pressProgram);
                        } else {
                            if (pressProgram != res.data.pressProgram) {
                                Topro.UI.Alert({ content: "不一样" });
                            }
                        }
                        
                        //判断是否有值
                        var bookBuildupStructure = $("input[name='bookBuildupStructure']").val();
                        if (Topro.Util.isNullOrEmptySpance(bookBuildupStructure)) {
                            $("input[name='bookBuildupStructure']").val(res.data.bookBuildupStructure);
                        } else {
                            if (bookBuildupStructure != res.data.bookBuildupStructure) {
                                Topro.UI.Alert({ content: "不一样" });
                            }
                        }

                        $("input[name='programbarCode']").val("");
                        //获取焦点
                        $("input[name='cuFoilNum']").focus();

                    } else {
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }

    });
    //Cu Foil Num 铜箔编号
    $("input[name='cuFoilNum']").keydown(function (e) {

        if (e.keyCode == 13) {

            var content = $(this).val();

            var data = {
                cuFoilNum: cuFoilNum,
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/CuFoilNum",
                data: data,
                success: function (res) {
                    if (res.success) {
                        $("input[name='cuFoilNum']").val(res.data.cuFoilNum);
                        $("input[name='cuFoilBatchNum']").val(res.data.cuFoilBatch);
                        //获取焦点
                        $("input[name='cuFoilExpire']").focus();
                    } else {
                        $("input[name='cuFoilNum']").val("");
                        $("input[name='cuFoilBatchNum']").val("");
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }

    });
    //Cu Foil Expire 铜箔有效期
    $("input[name='cuFoilExpire']").keydown(function (e) {
        if (e.keyCode == 13) {
            //获取焦点
            $("input[name='ppNumber']").focus();
            return false;
        }
    });
    //Package Num包号1_1
    $("input[name='packageNum1_1']").keydown(function (e) {
        if (e.keyCode == 13) {
            var content = $(this).val();

            var data = {
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/packageNum1_1",
                data: data,
                success: function (res) {
                    if (res.success) {
                        $("input[name='packageNum1_1']").val(res.data.packageNum);
                        //获取焦点
                        $("input[name='ppPcfPartNum1_1']").focus();
                    } else {
                        $("input[name='packageNum1_1']").val("");
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }
    });
    //PP/PCF 料号1_1
    $("input[name='ppPcfPartNum1_1']").keydown(function (e) {
        if (e.keyCode == 13) {

            var content = $(this).val();

            var data = {
                LOTPPRCFPartNum1: LOTPPRCFPartNum1,
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/PpPcfPartNum1_1",
                data: data,
                success: function (res) {
                    if (res.success) {
                        $("input[name='ppPcfPartNum1_1']").val(res.data.ppPcfPartNum1);
                        $("input[name='ppPcfBatchNum1_1']").val(res.data.ppPcfBatchNum1);
                        //获取焦点
                        $("input[name='ppPcfExpire1_1']").focus();
                    } else {
                        $("input[name='ppPcfPartNum1_1']").val('');
                        $("input[name='ppPcfBatchNum1_1']").val('');
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }
    });
    //PP/PCF 有效期1_1
    $("input[name='ppPcfExpire1_1']").keydown(function (e) {
        if (e.keyCode == 13) {

            var content = $(this).val();

            var data = {
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/ppPcfExpire1_1",
                data: data,
                success: function (res) {
                    if (res.success) {
                        //获取焦点
                        $("input[name='postponedMaterial1']").focus();
                    } else {
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }
    });
    //Package Num包号1_2
    $("input[name='packageNum1_2']").keydown(function (e) {
        if (e.keyCode == 13) {
            var content = $(this).val();

            var data = {
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/packageNum1_2",
                data: data,
                success: function (res) {
                    if (res.success) {
                        $("input[name='packageNum1_2']").val(res.data.packageNum);
                        //获取焦点
                        $("input[name='ppPcfPartNum1_2']").focus();
                    } else {
                        $("input[name='packageNum1_2']").val("");
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }
    });
    //PP/PCF 料号1_2
    $("input[name='ppPcfPartNum1_2']").keydown(function (e) {
        if (e.keyCode == 13) {

            var content = $(this).val();

            var data = {
                LOTPPRCFPartNum1: LOTPPRCFPartNum1,
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/PpPcfPartNum1_2",
                data: data,
                success: function (res) {
                    if (res.success) {
                        $("input[name='ppPcfPartNum1_2']").val(res.data.ppPcfPartNum1);
                        $("input[name='ppPcfBatchNum1_2']").val(res.data.ppPcfBatchNum1);
                        //获取焦点
                        $("input[name='ppPcfExpire1_2']").focus();
                    } else {
                        $("input[name='ppPcfPartNum1_2']").val('');
                        $("input[name='ppPcfBatchNum1_2']").val('');
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }
    });
    //PP/PCF 有效期1_2
    $("input[name='ppPcfExpire1_2']").keydown(function (e) {
        if (e.keyCode == 13) {

            var content = $(this).val();

            var data = {
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/ppPcfExpire1_2",
                data: data,
                success: function (res) {
                    if (res.success) {
                        //获取焦点
                        $("input[name='postponedMaterial2']").focus();
                    } else {
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }
    });
    //Package Num包号2_1
    $("input[name='packageNum2_1']").keydown(function (e) {
        if (e.keyCode == 13) {
            var content = $(this).val();

            var data = {
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/packageNum2_1",
                data: data,
                success: function (res) {
                    if (res.success) {
                        $("input[name='packageNum2_1']").val(res.data.packageNum);
                        //获取焦点
                        $("input[name='ppPcfPartNum2_1']").focus();
                    } else {
                        $("input[name='packageNum2_1']").val("");
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }
    });
    //PP/PCF 料号2_1
    $("input[name='ppPcfPartNum2_1']").keydown(function (e) {
        if (e.keyCode == 13) {

            var content = $(this).val();

            var data = {
                LOTPPRCFPartNum2: LOTPPRCFPartNum2,
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/PpPcfPartNum2_1",
                data: data,
                success: function (res) {
                    if (res.success) {
                        $("input[name='ppPcfPartNum2_1']").val(res.data[0]);
                        $("input[name='ppPcfBatchNum2_1']").val(res.data[1]);
                        //获取焦点
                        $("input[name='ppPcfExpire2_1']").focus();
                    } else {
                        $("input[name='ppPcfPartNum2_1']").val('');
                        $("input[name='ppPcfBatchNum2_1']").val('');
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }
    });
    //PP/PCF 有效期2_1
    $("input[name='ppPcfExpire2_1']").keydown(function (e) {
        if (e.keyCode == 13) {

            var content = $(this).val();

            var data = {
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/PpPcfExpire2_1",
                data: data,
                success: function (res) {
                    if (res.success) {
                        //获取焦点
                        $("input[name='postponedMaterial2_1']").focus();
                    } else {
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });
            return false;
        }
    });
    //Package Num包号2_2
    $("input[name='packageNum2_2']").keydown(function (e) {
        if (e.keyCode == 13) {
            var content = $(this).val();

            var data = {
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/packageNum2_2",
                data: data,
                success: function (res) {
                    if (res.success) {
                        $("input[name='packageNum2_2']").val(res.data.packageNum);
                        //获取焦点
                        $("input[name='ppPcfPartNum2_2']").focus();
                    } else {
                        $("input[name='packageNum2_2']").val("");
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }
    });
    //PP/PCF 料号2_2
    $("input[name='ppPcfPartNum2_2']").keydown(function (e) {
        if (e.keyCode == 13) {

            var content = $(this).val();

            var data = {
                LOTPPRCFPartNum2: LOTPPRCFPartNum2,
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/PpPcfPartNum2_2",
                data: data,
                success: function (res) {
                    if (res.success) {
                        $("input[name='ppPcfPartNum2_2']").val(res.data[0]);
                        $("input[name='ppPcfBatchNum2_2']").val(res.data[1]);
                        //获取焦点
                        $("input[name='ppPcfExpire2_2']").focus();
                    } else {
                        $("input[name='ppPcfPartNum2_2']").val('');
                        $("input[name='ppPcfBatchNum2_2']").val('');
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

            return false;
        }
    });
    //PP/PCF 有效期2_2
    $("input[name='ppPcfExpire2_2']").keydown(function (e) {
        if (e.keyCode == 13) {

            var content = $(this).val();

            var data = {
                content: content
            };

            Topro.Util.Ajax({
                type: "POST",
                url: "/Default/PpPcfExpire2_2",
                data: data,
                success: function (res) {
                    if (res.success) {
                        //获取焦点
                        $("input[name='postponedMaterial2_2']").focus();
                    } else {
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });
            return false;
        }
    });

    //Rotate Layup 旋转叠板
    $(".rotateLayup").click(function () {

        var cover = Topro.UI.Mask({
            obj: $("body"),
            opacity: 0.5
        });

        setTimeout(function () {
            cover.Remove();
        }, 1000);

        return false;
    });
    //保存
    $(".save").click(function () {
        save();
    });
    //关闭
    $(".reset").click(function () {
        reset();
    });
    //关闭
    $(".load").click(function () {
        load();
    });
});

function reset() {
    //Plant Num 厂号
    //$("input[name='plntNum']").val('');
    //Staff Num 员工号
    //$("input[name='staffNum']").val('');
    //Shift Num 班次
    //$("select[name='shiftNum']").find("option[value='']").attr("selected", true);
    //Equipment Code 设备编码
    //$("input[name='equipmentCode']").val('');
    //Lot 批号(上条码)：
    $("input[name='lotBatch']").val('');
    //Part Num 料号
    $("input[name='partNum']").val('');
    //Heap Number 叠合次数号
    $("input[name='heapNumber']").val('');
    //Material Type 材料类型
    $("input[name='materialType']").val('');
    //下条码扫描提示信息
    $(".barCode").html('流程卡物料/程式条形码还未扫描');
    //Press Program 压合程式
    $("input[name='pressProgram']").val('');
    //Cu Foil Num 铜箔编号
    $("input[name='cuFoilNum']").val('');
    //Cu Foil Batch 铜箔批号
    $("input[name='cuFoilBatchNum']").val('');
    //Cu Foil Expire 铜箔有效期
    $("input[name='cuFoilExpire']").val('');
    //PP 半固化片种类数
    $("input[name='ppTypeNumber']").val('');
    //PP 半固化片数量
    $("input[name='ppNumber']").val('');
    //PP1
    //Postponed Material1零包OR整包
    $("select[name='postponedMaterialType1']").find("option[value=0]").attr("selected", true);

    //1_1
    //Package Num包号1_1
    $("input[name='packageNum1_1']").val('');
    //PP/PCF 料号1_1
    $("input[name='ppPcfPartNum1_1']").val('');
    //PP/PCF 批号1_1
    $("input[name='ppPcfBatchNum1_1']").val('');
    //PP/PCF 有效期1_1
    $("input[name='ppPcfExpire1_1']").val('');
    //Postponed Material延期材料1_1
    $("select[name='postponedMaterial1_1']").find("option[value=0]").attr("selected", true);

    //1_2
    //Package Num包号1_2
    $("input[name='packageNum1_2']").val('');
    //PP/PCF 料号1_2
    $("input[name='ppPcfPartNum1_2']").val('');
    //PP/PCF 批号1_2
    $("input[name='ppPcfBatchNum1_2']").val('');
    //PP/PCF 有效期1_2
    $("input[name='ppPcfExpire1_2']").val('');
    //Postponed Material延期材料1_2
    $("select[name='postponedMaterial1_2']").find("option[value=0]").attr("selected", true);

    //PP2
    //Postponed Material2零包OR整包
    $("select[name='postponedMaterialType2']").find("option[value=0]").attr("selected", true);
    //2_1
    //Package Num包号2_1
    $("input[name='packageNum2_1']").val('');
    //PP/PCF 料号1_1
    $("input[name='ppPcfPartNum2_1']").val('');
    //PP/PCF 批号1_1
    $("input[name='ppPcfBatchNum2_1']").val('');
    //PP/PCF 有效期1_1
    $("input[name='ppPcfExpire2_1']").val('');
    //Postponed Material延期材料1_1
    $("select[name='postponedMaterial2_1']").find("option[value=0]").attr("selected", true);
    //2_2
    //Package Num包号2_2
    $("input[name='packageNum2_2']").val('');
    //PP/PCF 料号1_2
    $("input[name='ppPcfPartNum2_2']").val('');
    //PP/PCF 批号1_2
    $("input[name='ppPcfBatchNum2_2']").val('');
    //PP/PCF 有效期1_2
    $("input[name='ppPcfExpire2_2']").val('');
    //Postponed Material延期材料1_1
    $("select[name='postponedMaterial2_2']").find("option[value=0]").attr("selected", true);

    //Book Buildup Structure满本结构
    $("input[name='bookBuildupStructure']").val('');
    //1.5mm Plate 垫厚钢板数
    $("input[name='plateNum']").val('');
    //Panel Quan 板数
    $("input[name='panelQuan']").val('');
    //Secion Quan 含切片的板数
    $("input[name='secionQuan']").val('');
    //Alpha Board Stay Time棕化停留时间
    $("input[name='alphaBoardStayTime']").val('');
    //Stopper Quality 防滑质量
    $("select[name='stopperQuality']").find("option[value=0]").attr("selected", true);
    //Perpreg Surface Quality 表面质量
    $("select[name='perpregSurfaceQuality']").find("option[value=0]").attr("selected", true);
    //14 Pcs Kraft Quality 14张牛皮纸数量
    $("select[name='pcsKraftQuality']").find("option[value=0]").attr("selected", true);
    //Inner Core Quality 内层芯板质量
    $("select[name='innerCoreQuality']").find("option[value=0]").attr("selected", true);
    //Copper Foil Quality 铜箔质量
    $("select[name='copperFoilQuality']").find("option[value=0]").attr("selected", true);
    //Abnormal Steel Plate Quantity异常钢板
    $("input[name='abnormalSteelPlateQuantity']").val('');
    //备注
    $("input[name='remark']").val('');
}

function load() {

    debugger;

    Topro.Util.Ajax({
        type: "POST",
        url: "/Default/Book",
        data: null,
        success: function (res) {
            if (res.success) {
                //Plant Num 厂号
                //$("input[name='plntNum']").val('');
                //Staff Num 员工号
                //$("input[name='staffNum']").val('');
                //Shift Num 班次
                //$("select[name='shiftNum']").find("option[value='']").attr("selected", true);
                //Equipment Code 设备编码
                //$("input[name='equipmentCode']").val('');
                //Lot 批号(上条码)：
                $("input[name='lotBatch']").val('');
                //Part Num 料号
                $("input[name='partNum']").val('');
                //Heap Number 叠合次数号
                $("input[name='heapNumber']").val('');
                //Material Type 材料类型
                $("input[name='materialType']").val('');
                //下条码扫描提示信息
                $(".barCode").html('流程卡物料/程式条形码还未扫描');
                //Press Program 压合程式
                $("input[name='pressProgram']").val('');
                //Cu Foil Num 铜箔编号
                $("input[name='cuFoilNum']").val('');
                //Cu Foil Batch 铜箔批号
                $("input[name='cuFoilBatchNum']").val('');
                //Cu Foil Expire 铜箔有效期
                $("input[name='cuFoilExpire']").val('');
                //PP 半固化片种类数
                $("input[name='ppTypeNumber']").val('');
                //PP 半固化片数量
                $("input[name='ppNumber']").val('');
                //PP1
                //Postponed Material1零包OR整包
                $("select[name='postponedMaterialType1']").find("option[value=0]").attr("selected", true);

                //1_1
                //Package Num包号1_1
                $("input[name='packageNum1_1']").val('');
                //PP/PCF 料号1_1
                $("input[name='ppPcfPartNum1_1']").val('');
                //PP/PCF 批号1_1
                $("input[name='ppPcfBatchNum1_1']").val('');
                //PP/PCF 有效期1_1
                $("input[name='ppPcfExpire1_1']").val('');
                //Postponed Material延期材料1_1
                $("select[name='postponedMaterial1_1']").find("option[value=0]").attr("selected", true);

                //1_2
                //Package Num包号1_2
                $("input[name='packageNum1_2']").val('');
                //PP/PCF 料号1_2
                $("input[name='ppPcfPartNum1_2']").val('');
                //PP/PCF 批号1_2
                $("input[name='ppPcfBatchNum1_2']").val('');
                //PP/PCF 有效期1_2
                $("input[name='ppPcfExpire1_2']").val('');
                //Postponed Material延期材料1_2
                $("select[name='postponedMaterial1_2']").find("option[value=0]").attr("selected", true);

                //PP2
                //Postponed Material2零包OR整包
                $("select[name='postponedMaterialType2']").find("option[value=0]").attr("selected", true);
                //2_1
                //Package Num包号2_1
                $("input[name='packageNum2_1']").val('');
                //PP/PCF 料号1_1
                $("input[name='ppPcfPartNum2_1']").val('');
                //PP/PCF 批号1_1
                $("input[name='ppPcfBatchNum2_1']").val('');
                //PP/PCF 有效期1_1
                $("input[name='ppPcfExpire2_1']").val('');
                //Postponed Material延期材料1_1
                $("select[name='postponedMaterial2_1']").find("option[value=0]").attr("selected", true);
                //2_2
                //Package Num包号2_2
                $("input[name='packageNum2_2']").val('');
                //PP/PCF 料号1_2
                $("input[name='ppPcfPartNum2_2']").val('');
                //PP/PCF 批号1_2
                $("input[name='ppPcfBatchNum2_2']").val('');
                //PP/PCF 有效期1_2
                $("input[name='ppPcfExpire2_2']").val('');
                //Postponed Material延期材料1_1
                $("select[name='postponedMaterial2_2']").find("option[value=0]").attr("selected", true);

                //Book Buildup Structure满本结构
                $("input[name='bookBuildupStructure']").val('');
                //1.5mm Plate 垫厚钢板数
                $("input[name='plateNum']").val('');
                //Panel Quan 板数
                $("input[name='panelQuan']").val('');
                //Secion Quan 含切片的板数
                $("input[name='secionQuan']").val('');
                //Alpha Board Stay Time棕化停留时间
                $("input[name='alphaBoardStayTime']").val('');
                //Stopper Quality 防滑质量
                $("select[name='stopperQuality']").find("option[value=0]").attr("selected", true);
                //Perpreg Surface Quality 表面质量
                $("select[name='perpregSurfaceQuality']").find("option[value=0]").attr("selected", true);
                //14 Pcs Kraft Quality 14张牛皮纸数量
                $("select[name='pcsKraftQuality']").find("option[value=0]").attr("selected", true);
                //Inner Core Quality 内层芯板质量
                $("select[name='innerCoreQuality']").find("option[value=0]").attr("selected", true);
                //Copper Foil Quality 铜箔质量
                $("select[name='copperFoilQuality']").find("option[value=0]").attr("selected", true);
                //Abnormal Steel Plate Quantity异常钢板
                $("input[name='abnormalSteelPlateQuantity']").val('');
                //备注
                $("input[name='remark']").val('');
            }
        },
        error: function (json) {
        }
    });
}

function save() {

    var data = $("#form").serializeJSON();
    
    //编号
    data.id = $("input[name='id']").val();
    //料号1
    data.LOTPPRCFPartNum1 = LOTPPRCFPartNum1;
    //料号2
    data.LOTPPRCFPartNum2 = LOTPPRCFPartNum2;
    //Plant Num 厂号
    data.plntNum = $("input[name='plntNum']").val();
    //Staff Num 员工号
    data.staffNum = $("input[name='staffNum']").val();
    //Shift Num 班次
    data.shiftNum = $("select[name='shiftNum']").find("option:selected").val();
    //Equipment Code 设备编码
    data.equipmentCode = $("input[name='equipmentCode']").val();
    //Lot 批号(上条码)：
    data.lotBatch = $("input[name='lotBatch']").val();
    //Part Num 料号
    data.partNum = $("input[name='partNum']").val();
    //Heap Number 叠合次数号
    data.heapNumber = $("input[name='heapNumber']").val();
    //Material Type 材料类型
    data.materialType = $("input[name='materialType']").val();
    //Press Program 压合程式
    data.pressProgram = $("input[name='pressProgram']").val();
    //Cu Foil Num 铜箔编号
    data.cuFoilNum = $("input[name='cuFoilNum']").val();
    //Cu Foil Batch 铜箔批号
    data.cuFoilBatchNum = $("input[name='cuFoilBatchNum']").val();
    //Cu Foil Expire 铜箔有效期
    data.cuFoilExpire = $("input[name='cuFoilExpire']").val();
    //PP 半固化片种类数
    data.ppTypeNumber = $("input[name='ppTypeNumber']").val();
    //PP 半固化片数量
    data.ppNumber = $("input[name='ppNumber']").val();
    //PP1
    //Postponed Material1零包OR整包
    data.postponedMaterialType1 = $("select[name='postponedMaterialType1']").find("option:selected").val();

    //1_1
    //Package Num包号1_1
    data.packageNum1_1 = $("input[name='packageNum1_1']").val();
    //PP/PCF 料号1_1
    data.ppPcfPartNum1_1 = $("input[name='ppPcfPartNum1_1']").val();
    //PP/PCF 批号1_1
    data.ppPcfBatchNum1_1 = $("input[name='ppPcfBatchNum1_1']").val();
    //PP/PCF 有效期1_1
    data.ppPcfExpire1_1 = $("input[name='ppPcfExpire1_1']").val();
    //Postponed Material延期材料1_1
    data.postponedMaterial1_1 = $("select[name='postponedMaterial1_1']").find("option:selected").val();

    //1_2
    //Package Num包号1_2
    data.packageNum1_2 = $("input[name='packageNum1_2']").val();
    //PP/PCF 料号1_2
    data.ppPcfPartNum1_2 = $("input[name='ppPcfPartNum1_2']").val();
    //PP/PCF 批号1_2
    data.ppPcfBatchNum1_2 = $("input[name='ppPcfBatchNum1_2']").val();
    //PP/PCF 有效期1_2
    data.ppPcfExpire1_2 = $("input[name='ppPcfExpire1_2']").val();
    //Postponed Material延期材料1_2
    data.postponedMaterial1_2 = $("select[name='postponedMaterial1_2']").find("option:selected").val();

    //PP2
    //Postponed Material2零包OR整包
    data.postponedMaterialType2 = $("select[name='postponedMaterialType2']").find("option:selected").val();
    //2_1
    //Package Num包号2_1
    data.packageNum2_1 = $("input[name='packageNum2_1']").val();
    //PP/PCF 料号1_1
    data.ppPcfPartNum2_1 = $("input[name='ppPcfPartNum2_1']").val();
    //PP/PCF 批号1_1
    data.ppPcfBatchNum2_1 = $("input[name='ppPcfBatchNum2_1']").val();
    //PP/PCF 有效期1_1
    data.ppPcfExpire2_1 = $("input[name='ppPcfExpire2_1']").val();
    //Postponed Material延期材料1_1
    data.postponedMaterial2_1 = $("select[name='postponedMaterial2_1']").find("option:selected").val();
    //2_2
    //Package Num包号2_2
    data.packageNum2_2 = $("input[name='packageNum2_2']").val();
    //PP/PCF 料号1_2
    data.ppPcfPartNum2_2 = $("input[name='ppPcfPartNum2_2']").val();
    //PP/PCF 批号1_2
    data.ppPcfBatchNum2_2 = $("input[name='ppPcfBatchNum2_2']").val();
    //PP/PCF 有效期1_2
    data.ppPcfExpire2_2 = $("input[name='ppPcfExpire2_2']").val();
    //Postponed Material延期材料1_1
    data.postponedMaterial2_2 = $("select[name='postponedMaterial2_2']").find("option:selected").val();

    //Book Buildup Structure满本结构
    data.bookBuildupStructure = $("input[name='bookBuildupStructure']").val();
    //1.5mm Plate 垫厚钢板数
    data.plateNum = $("input[name='plateNum']").val();
    //Panel Quan 板数
    data.panelQuan = $("input[name='panelQuan']").val();
    //Secion Quan 含切片的板数
    data.secionQuan = $("input[name='secionQuan']").val();
    //Alpha Board Stay Time棕化停留时间
    data.alphaBoardStayTime = $("input[name='alphaBoardStayTime']").val();
    //Stopper Quality 防滑质量
    data.stopperQuality = $("select[name='stopperQuality']").find("option:selected").val();
    //Perpreg Surface Quality 表面质量
    data.perpregSurfaceQuality = $("select[name='perpregSurfaceQuality']").find("option:selected").val();
    //14 Pcs Kraft Quality 14张牛皮纸数量
    data.pcsKraftQuality = $("select[name='pcsKraftQuality']").find("option:selected").val();
    //Inner Core Quality 内层芯板质量
    data.innerCoreQuality = $("select[name='innerCoreQuality']").find("option:selected").val();
    //Copper Foil Quality 铜箔质量
    data.copperFoilQuality = $("select[name='copperFoilQuality']").find("option:selected").val();
    //Abnormal Steel Plate Quantity异常钢板
    data.abnormalSteelPlateQuantity = $("input[name='abnormalSteelPlateQuantity']").val();
    //备注
    data.remark = $("input[name='remark']").val();

    Topro.Util.Ajax({
        type: "POST",
        url: "/Default/SaveIQS",
        data: data,
        success: function (res) {
            if (res.success) {
                Topro.UI.DialogBox({
                    id: 'dialog_confirm',
                    title: '操作',
                    parent: true,
                    lock: true,
                    fixed: true,
                    icon: 'question',
                    padding: '20px 15px 20px 10px',
                    ok: function () {
                        
                    },
                    width: '200px',
                    content: '新增成功！',
                    cancel: function () {
                    }
                });

                reset();
            } else {
                Topro.UI.DialogBox({
                    id: 'dialog_confirm',
                    title: '操作',
                    parent: true,
                    lock: true,
                    fixed: true,
                    icon: 'question',
                    padding: '20px 15px 20px 10px',
                    ok: function () {
                    },
                    width: '200px',
                    content: "操作失败！" + res.message,
                    cancel: function () {
                    }
                });
            }
        },
        error: function (json) {
            cover.Remove();
            Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
        }
    });

}

function insertRow(obj) {

    if (obj.Type != undefined) {
        switch (obj.Type) {
            case 10:
                $("input[name='heapNumber']").val(obj.Name);
                break;
            case 20:
                $("input[name='materialType']").val(obj.Name);
                break;
            case 30:
                $("input[name='pressProgram']").val(obj.Name);
                break;
            case 40:
                $("input[name='bookBuildupStructure']").val(obj.Name);
                break;

            case 181:
                $("input[name='postponedMaterial1']").val(obj.Name);
                break;
            case 221:
                $("input[name='postponedMaterial2']").val(obj.Name);
                break;
            case 230:
                $("input[name='plaeType']").val(obj.Name);
                break;

            case 280:
                $("input[name='rotateLayup']").val(obj.Name);
                break;
        }
    }

}